<template>
	<div class='category'>
		<!-- 切换的点击区域 -->
		<ul class="title-ul">
			<li v-for="item in tabs" :key="item.id" :class="{'default':iscur===item.id}" @click="iscur = item.id">
				{{item.name}}
				<span class="default-span"></span>
			</li>
		</ul>
		<!-- 调用两个子组件 -->
		<CategoryTab1 v-if='iscur ===1'></CategoryTab1>
		<CategoryTab2 v-if='iscur ===2'></CategoryTab2>
	</div>
</template>

<script>
	import CategoryTab1 from './CategoryTab1.vue'
	import CategoryTab2 from './CategoryTab2.vue'
	
	export default{
		name:'Category',
		components:{
			CategoryTab1,
			CategoryTab2
		},
		data(){
			return{
				tabs:[
					{id:1,name:'热门度假'},
					{id:2,name:'热门景点'},
				],
				iscur:1, //默认选中第一个标题以及第一个组件
			}
		}
	}
</script>

<style scoped>
	.category{
		width: 90%;
		margin: 0.5rem auto;
		height: 10.3rem;
	}
	.category .title-ul{
		height: 1.17rem;
		background-color: #EEEEEE;
		width: 100%;
		border-radius: 0.3rem;
		display: flex;
		align-items: center;
	}
	.category .title-ul li{
		width: 50%;
		text-align: center;
		line-height: 1.17rem;
		font-size: 0.35rem;
		font-weight: bold;
		border-radius: 0.3rem;
		position: relative;
	}
	.category .title-ul .default{
		background-color: white;
	}
	.category .title-ul .default .default-span{
		display: block;
		background-color: gold;
		height: 0.1rem;
		width: 1rem;
		position: absolute;
		left: 39%;
		bottom: 18%;
	}
</style>
